import request from '@/utils/request'

enum Api {
  // 添加skuInfo
  saveSkuInfoApi = '/admin/product/saveSkuInfo',
  // 根据spuId查看其skuList数据
  checkSkuListApi = '/admin/product/findBySpuId',
  // 获取所有skuList数据
  getAllSkuListApi = '/admin/product/list',
  // skuInfo上架
  skuOnSaleApi = '/admin/product/onSale',
  // skuInfo下架
  skuCancelApi = '/admin/product/cancelSale',
  // 删除skuInfo
  deleteSkuInfoApi = '/admin/product/deleteSku',
  // 查看skuInfo数据
  getSkuInfoApi = '/admin/product/getSkuById',
}

// 接口函数
export const reqSaveSkuInfo = (skuInfo) =>{
  return request.post(Api.saveSkuInfoApi, skuInfo)
}
export const reqCheckSkuListData = (spuId) =>{
  return request.get(Api.checkSkuListApi + `/${spuId}`)
}
export const reqGetAllSkuListData = (page: number, limit: number) =>{
  return request.get(Api.getAllSkuListApi + `/${page}/${limit}`)
}
export const reqSkuOnSale = (skuId) =>{
  return request.get(Api.skuOnSaleApi + `/${skuId}`)
}
export const reqSkuCancelSale = (skuId) =>{
  return request({
    url: Api.skuCancelApi + `/${skuId}`,
    method: 'get'
  })
}
export const reqDeleteSkuInfo = (skuId) =>{
  return request.delete(Api.deleteSkuInfoApi + `/${skuId}`)
}
export const reqGetSkuInfoData = (skuId) =>{
  return request.get(Api.getSkuInfoApi + `/${skuId}`)
}